/*
 * Copyright (c)  2015~2020, xforceplus
 * All rights reserved.
 * Project:datacare-orm
 * Id: SQLTemplateEngine.java   2020-10-10 21-30-54
 * Author: Evan
 */
package cn.datacare.orm.engine;

import org.beetl.core.GroupTemplate;
import org.beetl.core.Resource;
import org.beetl.core.engine.DefaultTemplateEngine;
import org.beetl.core.engine.GrammarCreator;
import org.beetl.core.statement.Program;

import java.io.Reader;
import java.util.Map;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: 2015~2020
 * </p>
 * <p>
 * Company/Department: xforceplus
 * </p>
 *
 * @author Evan
 * <b>Creation Time:</b> 2020-10-10 21-30-54
 * @since V1.0
 */
public class SqlTemplateEngine extends DefaultTemplateEngine {

    /**
     *
     * @param resource
     * @param reader
     * @param textMap
     * @param cr
     * @param gt
     * @return
     */
    @Override
    public Program createProgram(Resource resource, Reader reader, Map<Integer, String> textMap, String cr,
                                 GroupTemplate gt) {
       return super.createProgram(resource, reader, textMap, cr, gt);
    }


    /**
     * 语法节点生成器，子类可以扩展射生成自己个性化节点解析，比如带有xss的输出的${}，限制循环个数的for语法
     *
     * @param gt
     * @return
     */
    @Override
    protected GrammarCreator getGrammerCreator(GroupTemplate gt) {
       return  new SqlGrammarCreator();
    }
}
